package org.labuladong.前缀和技巧;

/**
 * @Auther: qingle
 * @Date: 2024/10/26-11:39
 * @Description:
 * @version: 1.0
 */
public class 前缀和 {


	//nums = [2,3,1,1,4]
	public static void main(String[] args) {

		int[] nums = {2,3,1,1,4};

		int sumAccumulate = 0;
		int[] sum = new int[nums.length];
		for (int i = 0; i < nums.length; i++) {
			sumAccumulate += nums[i];
			sum[i] = sumAccumulate;
		}

		for (int i = 0; i < sum.length; i++) {
			System.out.println(sum[i]);
		}
	}
}
